/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.acq.service.plantinfo;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.acq.dao.plantinfo.AcqPlantInfoDao;
import com.thinkgem.jeesite.modules.acq.entity.plantinfo.AcqPlantInfo;

/**
 * 种植品信息Service
 * @author lj
 * @version 2018-04-16
 */
@Service
@Transactional(readOnly = true)
public class AcqPlantInfoService extends CrudService<AcqPlantInfoDao, AcqPlantInfo> {

	public AcqPlantInfo get(String id) {
		return super.get(id);
	}
	
	public List<AcqPlantInfo> findList(AcqPlantInfo acqPlantInfo) {
		return super.findList(acqPlantInfo);
	}
	
	public Page<AcqPlantInfo> findPage(Page<AcqPlantInfo> page, AcqPlantInfo acqPlantInfo) {
		return super.findPage(page, acqPlantInfo);
	}
	
	@Transactional(readOnly = false)
	public void save(AcqPlantInfo acqPlantInfo) {
		super.save(acqPlantInfo);
	}
	
	@Transactional(readOnly = false)
	public void delete(AcqPlantInfo acqPlantInfo) {
		super.delete(acqPlantInfo);
	}
	
	@Transactional(readOnly = false)
	public Map<String,Object> saveInfo( AcqPlantInfo acqPlantInfo) {
		Map<String,Object> result = new HashMap<String,Object>();
		acqPlantInfo.setCreateDate(new Date());
		try{
			super.save(acqPlantInfo);
			result.put("success", true);
			result.put("msg", "成功");
			return result;
		}catch(Exception e){
			result.put("success", false);
			result.put("msg", "失败");
			e.printStackTrace();
			return result;
		}
	}
	@Transactional(readOnly = false)
	public List<Map<String,Object>> pie(String areaId) {
		return dao.pie(areaId);

	}
	@Transactional(readOnly = false)
	public  Map<String,Object> infoline(String areaId) {
		Map<String,Object> result = new HashMap<String,Object>();
		List<String> city = new ArrayList<String>();
		List<Double> data = new ArrayList<Double>();
		List<Map<String,Object>> list = dao.infoline(areaId);
		for(Map<String,Object> map :list){
			city.add((String)map.get("x"));
			data.add((Double)map.get("data"));
		}
		result.put("city",city);
		result.put("data",data);
		return result;
	}
	
}